areaCity
/**
 * Created by Administrator on 2017/8/18 0018.
 */

var business;
if (!business) {
    business = {};
}

var scopeRow;
// business.GoodFaith = function (value, row, index) {
//     var recommend = row.isRecommend;
//     if (recommend == 0) {
//         return [
//             '<div><a class="goodFaith" href="javascript:void(0)" style="color: #0bb20c">推荐诚信商家</a></div>'
//         ].join('');
//     } else if (recommend == 1) {
//         return [
//             '<a class="goodFaiths" href="javascript:void(0)" style="color: red">取消诚信商家</a>'
//         ].join('');
//     }
// };
// window.operateFaith = {
//     'click .goodFaith': function (e, value, row) {
//         comment.showOperationTips("确定推荐诚信商家吗？", function () {
//             $.post($().AbsUrlParse('/web/business/updateRecommend'), {
//                 id: row.id,
//                 isRecommend: 1,
//                 state: row.state
//             }, function (data) {
//                 if (data.state == true) {
//                     if (data.res.code == 40000) {
//                         hint("设置成功");
//                         var table = $("#table");
//                         table.bootstrapTable("refresh");
//                     } else {
//                         hint(data.res.msg);
//                     }
//                 } else {
//                     hint(data.msg);
//                 }
//             });
//         });
//     },
//     'click .goodFaiths': function (e, value, row) {
//         comment.showOperationTips("确定取消诚信商家吗？", function () {
//             $.post($().AbsUrlParse('/web/business/updateRecommend'), {
//                 id: row.id,
//                 isRecommend: 0,
//                 state: row.state
//             }, function (data) {
//                 if (data.state == true) {
//                     if (data.res.code == 40000) {
//                         hint("设置成功");
//                         var table = $("#table");
//                         table.bootstrapTable("refresh");
//                     } else {
//                         hint(data.res.msg);
//                     }
//                 } else {
//                     hint(data.msg);
//                 }
//             });
//         });
//     }
// };

business.payType = function (value, row, index) {
    if (row.payType == 1) {
        return [
            '<div><span >' + '支付宝' + '</span></div> '
        ].join('');
    } else if (row.payType == 2) {
        return [
            '<div ><span >' + '微信' + '</span></div> '
        ].join('');
    } else if (row.payType == 3) {
        return [
            '<div ><span >' + '支付宝 + 红包' + '</span></div> '
        ].join('');
    } else if (row.payType == 4) {
        return [
            '<div ><span >' + '微信 + 红包' + '</span></div> '
        ].join('');
    } else {
        return [
            '<div ><span >' + '红包抵扣' + '</span></div> '
        ].join('');
    }
};

business.state = function (value, row, index) {
    var state = row.state;
    if (state == 2) {
        return [
            '<div><a class="status" href="javascript:void(0)" style="color: #0bb20c">启用</a></div>'
        ].join('');
    } else if (state == 1) {
        return [
            '<a class="state" href="javascript:void(0)" style="color: red">禁用</a>'
        ].join('');
    }
};

window.operate = {
    'click .state': function (e, value, row) {
        comment.showOperationTips("确定要禁用商家吗？", function () {
            $.post($().AbsUrlParse('/web/business/updateStatus'), {id: row.id, state: 2}, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("设置成功");
                        var table = $("#table");
                        table.bootstrapTable("refresh");
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }
            });
        });
    },
    'click .status': function (e, value, row) {
        comment.showOperationTips("确定要启用商家吗？", function () {
            $.post($().AbsUrlParse('/web/business/updateStatus'), {id: row.id, state: 1}, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("设置成功");
                        var table = $("#table");
                        table.bootstrapTable("refresh");
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }
            });
        });
    }
};

business.operateFormatter = function (value, row, index) {

    var business = '<a class="business" href="javascript:void(0)" >商家详情</a>' + '&nbsp;&nbsp;';
    var order = '<a class="order" href="javascript:void(0)" >订单列表</a>' + '&nbsp;&nbsp;';
    var details = '<a class="details" href="javascript:void(0)" >收支明细</a>' + '&nbsp;&nbsp;';
    var update = '<a class="updateBusiness" href="javascript:void(0)" >修改商家</a>' + '&nbsp;&nbsp;';
    var goods = '<a class="goodsList" href="javascript:void(0)" >商品列表</a>' + '&nbsp;&nbsp;';
    var pwd = '<a class="pwd" href="javascript:void(0)" >重置密码</a>' + '&nbsp;&nbsp;';
    var coupon = '<a class="coupon" href="javascript:void(0)" >满减活动</a>' + '&nbsp;&nbsp;';
    // var remove = '<a class="remove" href="javascript:void(0)" style="color: red">删除商家</a>';
    return [
        '<div>' + business + order + details + update + '</div>' +
        '<div style="margin-top: 1%">' + goods + pwd + coupon  + '</div>'
    ].join('');
    // if (row.isPosition == 0) {
    //     return [
    //         '<a class="business" href="javascript:void(0)" >商家详情</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="order" href="javascript:void(0)" >订单列表</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="details" href="javascript:void(0)" >收支明细</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="updateBusiness" href="javascript:void(0)" >修改商家</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="pwd" href="javascript:void(0)" >重置密码</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="coupon" href="javascript:void(0)" >满减活动</a>' +
    //         '&nbsp;&nbsp;' +
    //         // '<a class="activity" href="javascript:void(0)" >优惠活动</a>' +
    //         // '&nbsp;&nbsp;' +
    //         // '<a class="businessAdvertising" href="javascript:void(0)" style="color: #00B83F" >推荐商家广告位</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="remove" href="javascript:void(0)" style="color: red">删除商家</a>'
    //     ].join('');
    // } else {
    //     return [
    //         '<a class="business" href="javascript:void(0)" >商家详情</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="order" href="javascript:void(0)" >订单列表</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="details" href="javascript:void(0)" >收支明细</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="updateBusiness" href="javascript:void(0)" >修改商家</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="pwd" href="javascript:void(0)" >重置密码</a>' +
    //         '&nbsp;&nbsp;' +
    //         '<a class="coupon" href="javascript:void(0)" >满减活动</a>' +
    //         '&nbsp;&nbsp;' +
    //         // '<a class="activity" href="javascript:void(0)" >优惠活动</a>' +
    //         // '&nbsp;&nbsp;' +
    //         // '<a class="businessAdvertisings" href="javascript:void(0)" style="color: red">取消推荐广告位</a>' +
    //         // '&nbsp;&nbsp;' +
    //         '<a class="remove" href="javascript:void(0)" style="color: red">删除商家</a>'
    //     ].join('');
    // }
};

window.operateEvent = {
    'click .order': function (e, value, row) {
        showModel("queryBusinessOrder-div", function () {
            var table = $("#orderBusiness");
            var url = $().AbsUrlParse("/web/business/businessOrderList?id=" + row.id);
            table.bootstrapTable("refresh", {url: url});
            payType = function (value, row, index) {
                if (row.payType == 1) {
                    return [
                        '<div><span >' + '支付宝' + '</span></div> '
                    ].join('');
                } else if (row.payType == 2) {
                    return [
                        '<div ><span >' + '微信' + '</span></div> '
                    ].join('');
                } else if (row.payType == 3) {
                    return [
                        '<div ><span >' + '支付宝 + 红包' + '</span></div> '
                    ].join('');
                } else if (row.payType == 4) {
                    return [
                        '<div ><span >' + '微信 + 红包' + '</span></div> '
                    ].join('');
                } else {
                    return [
                        '<div ><span >' + '红包抵扣' + '</span></div> '
                    ].join('');
                }
            };
            orderState = function (value, row, index) {
                if (row.orderState == 1) {
                    return [
                        '<div><span>待付款</span></div>'
                    ].join('');
                } else if (row.orderState == 2) {
                    return [
                        '<div><span>待接单</span></div>'
                    ].join('');
                } else if (row.orderState == 3) {
                    return [
                        '<div><span>待配送</span></div>'
                    ].join('');
                } else if (row.orderState == 4) {
                    return [
                        '<div><span>配送中</span></div>'
                    ].join('');
                } else if (row.orderState == 5) {
                    return [
                        '<div><span>待评价</span></div>'
                    ].join('');
                } else if (row.orderState == 6) {
                    return [
                        '<div><span>已完结</span></div>'
                    ].join('');
                } else if (row.orderState == 7) {
                    return [
                        '<div><span>申请退款</span></div>'
                    ].join('');
                } else if (row.orderState == 8) {
                    return [
                        '<div><span>拒绝接单</span></div>'
                    ].join('');
                } else if (row.orderState == 9) {
                    return [
                        '<div><span>同意退款</span></div>'
                    ].join('');
                } else if (row.orderState == 10) {
                    return [
                        '<div><span>拒绝退款</span></div>'
                    ].join('');
                } else if (row.orderState == 11) {
                    return [
                        '<div><span>取消订单</span></div>'
                    ].join('');
                } else if (row.orderState == 12) {
                    return [
                        '<div><span>待取货</span></div>'
                    ].join('');
                }
            }
        });
    },
    'click .details': function (e, value, row) {
        showModel("queryBusinessDetails-div", function () {
            var table = $("#details");
            var url = $().AbsUrlParse("/web/business/businessOrderDetails?id=" + row.id);
            table.bootstrapTable("refresh", {url: url});
            sourceType = function (value, row, index) {
                if (row.sourceType == 1) {
                    return [
                        '<div><span>收入</span></div>'
                    ].join('');
                } else if (row.sourceType == 2) {
                    return [
                        '<div><span>退货</span></div>'
                    ].join('');
                } else if (row.sourceType == 3) {
                    return [
                        '<div><span>提现</span></div>'
                    ].join('');
                }
            }
        });
    },
    'click .business': function (e, value, row) {
        showModel("businessDetails-div", function () {
            $("#id").val(row.id);
            $("#account").val(row.account);
            $("#businessName").val(row.bussName);
            $("#businessType").val(row.typeName);
            $("#businessPhone").val(row.bussTel);
            $("#emergencyContact").val(row.emergencyContact);
            $("#emergencyContactTel").val(row.emergencyContactTel);
            $("#telephone").val(row.bussTel);
            $("#start").val(row.startTime);
            $("#end").val(row.endTime);
            $("#address").val(row.adress);
            $("#getCity").val(row.cityId);

            var cityArea = function () {
                $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 4}, function (id) {
                    var select = $("#getCityArea");
                    select.empty();
                    select.append('<option value="0">-请选择-</option>');
                    if (id.res.code == 40000) {
                        var allData = id.res.data;
                        for (var i = 0; i < allData.length; i++) {
                            select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
                            $("#getCityArea").val(row.areaId);
                        }
                    }
                });
            };
            cityArea();

            var path = File_Download_Url;
            var licnese = path + row.bussLicnese;
            var card = path + row.legalCardPic;
            var service = path + row.serviceLince;

            $("#licneseShow").attr("src", licnese);
            $("#idCard").attr("src", card);
            $("#service").attr("src", service);

            var img = row.storePic;
            var imgs = img.split(",");
            var showPic = "";
            for (var i = 0; i < imgs.length; i++) {
                var imgUrl = path + imgs[i];
                showPic += '<div class="col-md-4"><image src=' + imgUrl + ' style="width:150px;height:150px;" onclick="enlargeImage(this)"/></div>';
            }
            $("#store").html(showPic);

            var shop = row.shopPic;
            var pic = shop.split(",");
            var showPicShop = "";
            for (var j = 0; j < pic.length; j++) {
                var url = path + pic[j];
                showPicShop += '<div class="col-md-4"><image src=' + url + ' style="width:150px;height:150px;" onclick="enlargeImage(this)"/></div>';
            }
            $("#instore").html(showPicShop);

            $("#editor").val(row.promotionName);
        });
    },
    'click .pwd': function (e, value, row) {
        showModel("updatePwd-div", function () {
            $("#ids").val(row.id);
        });
    },
    'click .coupon': function (e, value, row) {
        showModel("examineCoupon-div", function () {
            var url = $().AbsUrlParse("/web/business/examineCoupon?id=" + row.id);
            var table = $("#coupon");
            table.bootstrapTable("refresh", {url: url});
        });
    },
    // 'click .activity': function (e, value, row) {
    //     showModel("examineActivity-div", function () {
    //         var table = $("#activity");
    //         var url = $().AbsUrlParse("/web/business/examineActivity?id=" + row.id);
    //         table.bootstrapTable("refresh", {url: url});
    //     });
    // },
    'click .updateBusiness': function (e, value, row) {
        showModel("updateBusiness-div", function () {
            $("#updateId").val(row.id);
            $("#name").val(row.bussName);
            $("#selected").val(row.bussTypeId);
            $("#updatePhone").val(row.bussTel);
            $("#updateTel").val(row.bussTel);
            $("#updateAddress").val(row.adress);
            $("#cityIds").val(row.cityId);
            console.log(row.cityId);
            $("#areaCity").val(row.areaId);
            console.log(row.areaId);
            $("#sleep").val(row.areaId);
            var url = File_Download_Url;
            $("#serviceLince").attr("src", url + row.serviceLince);
            $("#serviceLince").attr("img-path", row.serviceLince);
            $("#busLicnese").attr("src", url + row.bussLicnese);
            $("#busLicnese").attr("img-path", row.bussLicnese);

            var areaCity = function () {
                $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 4, cityId: row.cityId}, function (id) {
                    var select = $("#areaCity");
                    select.empty();
                    select.append('<option value="0">-请选择-</option>');
                    if (id.res.code == 40000) {
                        var allData = id.res.data;
                        for (var i = 0; i < allData.length; i++) {
                            select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
                            $("#areaCity").val(row.areaId);
                        }
                    }
                });
            };
            areaCity();
        });
    },
    'click .remove': function (e, value, row) {
        comment.showOperationTips("确定删除吗？", function () {
            $.post($().AbsUrlParse('/web/business/updateStatus'), {
                id: row.id, state: 0
            }, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("删除成功");
                        var table = $("#table");
                        table.bootstrapTable("refresh");
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }
            });
        });
    },
    'click .businessAdvertising': function (e, value, row) {
        showModel("storePicRecommend-div", function () {
            $("#orderId").val(row.id);
            $("#cId").val(row.cId);
            $("#isPosition").val(1);
            $("#state").val(row.state);
            var url = File_Download_Url;
            $("#storePic").attr("src", url + row.storePic);
            $("#storePic").attr("img-path", row.storePic);
        });
    },
    'click .businessAdvertisings': function (e, value, row) {
        // $("#cityRecommend").val(row.link);
        comment.showOperationTips("确定要取消广告位吗？", function () {
            $.post($().AbsUrlParse('/web/business/updateIsPosition'), {
                id: row.id,
                isPosition: 0,
                state: row.state
            }, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("推荐成功");
                        var table = $("#table");
                        table.bootstrapTable("refresh");
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }
            });
        });
    },
    'click .goodsList': function (e, value, row) {
        showModel("goodsList-div", function () {
            $("#companyId").val(row.id);
            var table = $("#goods");
            var url = $().AbsUrlParse("/web/goods/businessGoods?id=" + row.id);
            table.bootstrapTable("refresh", {url: url});
            goodsPic = function (value, row, index) {
                var img = row.headPic;
                var imgs = img.split(",");
                var imgUrl = "";
                if (img != null && img != "") {
                    imgUrl = File_Download_Url + imgs[0];
                    return '<image src=' + imgUrl + ' style="width:80px;height:80px" onclick="enlargeImage(this)"/>';
                } else {
                    return '<image src=' + $().AbsUrlParse("/static/images/no.png") + ' style="width:80px;height:80px" onclick="enlargeImage(this)"/>'
                }
            };
            operateGoods = function () {
                return [
                    '<a class="goodsDelete" href="javascript:void(0)" >删除</a>'
                ].join('');
            };
        });
    }
};

// /**
//  *执行修改保存操作
//  * */
// bindClick("button[data-event=submit-updateBusiness]", function () {
//     var imagePath = $("#pic").attr("img-path");
//     $("#picture").val(imagePath);
//
//     var typeId = $("#selected").val();
//     $("#type").val(typeId);
//
//     var cityIds = $("#cityIds").val();
//     $("#city").val(cityIds);
//
//     var form = $("#updateBusinessFrom");
//     var v = form.valid();
//     if (v == false) {
//         return false;
//     }
//     var params = form.formToArray();
//     $.post($().AbsUrlParse("/web/business/updateBusinessInfo"), params, function (res) {
//         if (res.state && res.res.code == 40000) {
//             hint('修改成功！');
//             //关闭model方法
//             closeModel('updateBusiness-div');
//             var table = $("#table");
//             table.bootstrapTable("refresh");
//         } else {
//             if (res.state == false) {
//                 hint(res.msg);
//             } else {
//                 hint(res.res.msg);
//             }
//         }
//     });
// });

/**
 *执行修改保存操作
 * */
bindClick("button[data-event=submit-updatePwd]", function () {

    var form = $("#pwdFrom");
    var v = form.valid();
    if (v == false) {
        return false;
    }
    var params = form.formToArray();
    $.post($().AbsUrlParse("/web/business/updateBusinessPwd"), params, function (res) {
        if (res.state && res.res.code == 40000) {
            hint('修改成功！');
            //关闭model方法
            closeModel('updatePwd-div');
            var table = $("#table");
            table.bootstrapTable("refresh");
        } else {
            if (res.state == false) {
                hint(res.msg);
            } else {
                hint(res.res.msg);
            }
        }
    });
});

var getCityId = function () {
    $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 3}, function (id) {
        var select = $("#citys");
        select.empty();
        select.append('<option value="0">-城市选择-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
            }
        }
    });
};
getCityId();

var getTypeId = function () {
    $.post($().AbsUrlParse("/web/business/queryByTypeId"), null, function (id) {
        var select = $("#types");
        select.empty();
        select.append('<option value="0">-商家分类-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].typeName + '</option>');
            }
        }
    });
};
getTypeId();


function queryBusiness() {
    var name = $("#nameBusiness").val();
    var created = $("#created").val();
    var obj = created.split("-");
    var startCreate = obj[0] + "-" + obj[1] + "-" + obj[2];
    if (obj[1] == undefined) {
        startCreate = "";
    }
    var endCreate = obj[3] + "-" + obj[4] + "-" + obj[5];
    if (obj[4] == undefined) {
        endCreate = "";
    }
    var lastTime = $("#lastTime").val();
    var obj1 = lastTime.split("-");
    var startTime = obj1[0] + "-" + obj1[1] + "-" + obj1[2];
    if (obj1[1] == undefined) {
        startTime = "";
    }
    var endTime = obj1[3] + "-" + obj1[4] + "-" + obj1[5];
    if (obj1[4] == undefined) {
        endTime = "";
    }
    var typeId = $("#types").val();
    var cityId = $("#citys").val();
    var url = $().AbsUrlParse("/web/business/queryBusinessList?businessName=" + name + "&startCreate=" + startCreate + "&endCreate=" + endCreate +
        "&typeId=" + typeId + "&cityId=" + cityId + "&startTime=" + startTime + "&endTime=" + endTime + "offset=0");
    var table = $("#table");
    table.bootstrapTable("refresh", {url: url});
}

//商家详情 城市下拉列表
var getCityName = function () {
    $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 3}, function (id) {
        var select = $("#getCity");
        select.empty();
        select.append('<option value="0">-请选择-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
            }
        }
    });
};
//函数自调用
getCityName();
//修改商家 城市下拉列表数据载入
var cityInfo = function () {
    console.log("自调用cityInfo")
    $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 3}, function (id) {
        var select = $("#cityIds");
        select.empty();
        select.append('<option value="0">-请选择-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
            }
        }
    });
};
//函数自调用
cityInfo();

var cityBusinessType = function () {
    $.post($().AbsUrlParse("/web/business/queryByTypeId"), null, function (id) {
        var select = $("#selected");
        select.empty();
        select.append('<option value="0">-请选择-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].typeName + '</option>');
            }
        }
    });
};
cityBusinessType();


business.status = function (value, row, index) {
    if (row.state == 1) {
        return [
            '<div><span>启用</span></div>'
        ].join('');
    } else if (row.state == 2) {
        return [
            '<div><span>禁用</span></div>'
        ].join('');
    }
};

var cityRecommend = function () {
    $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 3}, function (id) {
        var select = $("#cityRecommend");
        select.empty();
        select.append('<option value="0">-请选择-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
            }
        }
    });
};
cityRecommend();


/**
 *执行修改保存操作
 * */
bindClick("button[data-event=submit-updateBusiness]", function () {
    var path = $("#serviceLince").attr("img-path");
    $("#updateServiceLince").val(path);

    var image = $("#busLicnese").attr("img-path");
    $("#updateBusLicnese").val(image);

    var typeId = $("#selected").val();
    $("#type").val(typeId);

    var cityIds = $("#cityIds").val();
    $("#city").val(cityIds);

    var areaCity = $("#areaCity").val();
    $("#area").val(areaCity);

    var form = $("#updateBusinessFrom");
    var v = form.valid();
    if (v == false) {
        return false;
    }
    var params = form.formToArray();
    $.post($().AbsUrlParse("/web/business/updateBusinessInfo"), params, function (res) {
        if (res.state && res.res.code == 40000) {
            hint('修改成功！');
            //关闭model方法
            closeModel('updateBusiness-div');
            var table = $("#table");
            table.bootstrapTable("refresh");
        } else {
            if (res.state == false) {
                hint(res.msg);
            } else {
                hint(res.res.msg);
            }
        }
    });
});

/**
 *执行修改保存操作
 * */
bindClick("button[data-event=submit-storePicRecommend]", function () {
    var re = $("#cityRecommend").val();
    $("#recommend").val(re);
    if (re == 0) {
        hint("请选择城市");
        return;
    }

    var store = $("#storePic").attr("img-path");
    $("#updateStorePic").val(store);
    if (store == null && store == "") {
        hint("请完善商家门店照片");
        return;
    }

    var form = $("#recommendFrom");
    var v = form.valid();
    if (v == false) {
        return false;
    }
    var params = form.formToArray();
    $.post($().AbsUrlParse("/web/business/updateIsPosition"), params, function (res) {
        if (res.state && res.res.code == 40000) {
            hint('修改成功！');
            //关闭model方法
            closeModel('storePicRecommend-div');
            var table = $("#table");
            table.bootstrapTable("refresh");
        } else {
            if (res.state == false) {
                hint(res.msg);
            } else {
                hint(res.res.msg);
            }
        }
    });
});

//修改商家 下拉列表点击事件
var areaCityInfo = function () {
    var city = $("#cityIds").val();
    var s = $("#sleep").val();
    $.post($().AbsUrlParse("/web/type/queryByCityId"), {deptPath: 4, cityId: city}, function (id) {
        var select = $("#areaCity");
        select.empty();
        select.append('<option value="0">-请选择-</option>');
        if (id.res.code == 40000) {
            var allData = id.res.data;
            console.log(allData)
            for (var i = 0; i < allData.length; i++) {
                select.append('<option value="' + allData[i].id + '">' + allData[i].name + '</option>');
                $("#areaCity").val(s);
            }
        }
    });
};


function initDateRange() {
    $(".rangedate").daterangepicker({
        "autoApply": true,
        "locale": {
            "applyLabel": "确定",
            "cancelLabel": "取消",
            "fromLabel": "开始",
            "toLabel": "结束",
            "customRangeLabel": "Custom",
            "weekLabel": "周",
            "daysOfWeek": [
                "日",
                "一",
                "二",
                "三",
                "四",
                "五",
                "六"
            ],
            "monthNames": [
                "1月",
                "2月",
                "3月",
                "4月",
                "5月",
                "6月",
                "7月",
                "8月",
                "9月",
                "10月",
                "11月",
                "12月"
            ],
            "cancelLabel": '清空',
            "opens": "right"
        },
        "format": "YYYY-MM-DD"
    }).on('cancel.daterangepicker', function (ev, picker) {
        $(this).val('');
    });
}

//初始化页面的时候运行该函数
$(function () {
    initDateRange();
});


operateFormatterDetail = function (value, row, index) {
    return [
        '<a class="goodsDetail" href="javascript:void(0)" >订单商品</a>'
    ].join('');
};

operateEventDetail = {
    'click .goodsDetail': function (e, value, row) {
        showModel("orderGoodsDetail-div", function () {
            var table = $("#orderGoodsDetail");
            var url = $().AbsUrlParse("/web/business/businessOrderDetail?orderNumber=" + row.orderNumber);
            table.bootstrapTable("refresh", {url: url});
        })
    },
    'click .goodsDelete': function (e, value, row) {
        comment.showOperationTips("确定删除吗？", function () {
            $.post($().AbsUrlParse('/web/goods/deleteGoodsById'), {
                id: row.id
            }, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("删除成功");
                        var table = $("#goods");
                        table.bootstrapTable("refresh");
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }
            });
        });
    }
};


function searchGoods() {
    var id = $("#companyId").val();
    var name = $("#nameGoods").val();
    var url = $().AbsUrlParse("/web/goods/businessGoods?goodsName=" + name + "&id=" + id);
    var table = $("#goods");
    table.bootstrapTable("refresh", {url: url});
}

function enlargeImage(value) {
    showModel("detailImage-div", function () {
        var imgs = '<image src=' + value.src + ' style="height:500px" />';
        $("#image").html(imgs);
    })
}

